with v8.Class_String;
with v8.Class_CPU_Profile_Node;
package v8.Class_CPU_Profile is
   type CPU_Profile (<>) is tagged limited private;
   type Pointer is access all CPU_Profile;
   type Readonly_Pointer is access constant CPU_Profile;
   -- CpuProfile contains a CPU profile in a form of two call trees:
   --  - top-down (from main() down to functions that do all the work);
   --  - bottom-up call graph (in backward direction).


   function Get_Uid (this : CPU_Profile) return unsigned;
   -- Returns CPU profile UID (assigned by the profiler.)

   function Get_Title (this : CPU_Profile) return v8.Class_String.Pointer;
   -- Returns CPU profile title.(return Handle<String>)

   function Get_Bottom_Up_Root
     (this : CPU_Profile
     ) return v8.Class_CPU_Profile_Node.Readonly_Pointer;
   -- Returns the root node of the bottom up call tree.

   function Get_Top_Down_Root
     (this : CPU_Profile
     ) return v8.Class_CPU_Profile_Node.Readonly_Pointer;
   -- Returns the root node of the top down call tree.

   procedure Delete (this : in out Cpu_Profile);
   -- Deletes the profile and removes it from CpuProfiler's list.
   -- All pointers to nodes previously returned become invalid.
   -- Profiles with the same uid but obtained using different
   -- security token are not deleted, but become inaccessible
   -- using FindProfile method. It is embedder's responsibility
   -- to call Delete on these profiles.

private
   type CPU_Profile is tagged limited null record;

   pragma Import (CPP, Get_Uid, "_ZNK2v810CpuProfile6GetUidEv");
   pragma Import (CPP, Get_Title, "_ZNK2v810CpuProfile8GetTitleEv");
   pragma Import (CPP, Get_Bottom_Up_Root, "_ZNK2v810CpuProfile15GetBottomUpRootEv");
   pragma Import (CPP, Get_Top_Down_Root, "_ZNK2v810CpuProfile14GetTopDownRootEv");
   pragma Import (CPP, Delete, "_ZN2v810CpuProfile6DeleteEv");
end v8.Class_CPU_Profile;
